<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 7/12/2021
  Time: 下午7:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        input{
            width: calc(100% - 50px);
            height: 36px;
            float: left;
            line-height: 36px;
        }
        span{

            height: 36px;
            float: left;
            line-height: 36px;
        }
        button{
            margin-top: 20px;
            position: center;
            width: 20%;
        }
        span{
            visibility: hidden;
            /*visibility: visible;*/
        }
        input{
            visibility: hidden;
            /*visibility: visible;*/
        }
        button{
            visibility: hidden;
            /*visibility: visible;*/
        }
    </style>
</head>
<body style="text-align: center" id="bd">
<select id="st" onchange="c()">
    <option id="op" ></option>
    <option id="op1" >蓝桥杯</option>
    <option id="op2" >希望杯</option>
    <option id="op3" >飞翔杯</option>
</select><br>
<%--<span>序号:</span><input id="in1" type="text"><br>--%>
<span>姓名:</span><input id="in2" type="text"><br>
<span>学号:</span><input id="in3" type="text"><br>
<span>性别:</span><input id="in4" type="text"><br>
<span>电话:</span><input id="in5" type="text"><br>
<span>邮箱:</span><input id="in6" type="text"><br>
<span>省份:</span><input id="in7" type="text"><br>
<span>地址:</span><input id="in8" type="text"><br>
<span>专业:</span><input id="in9" type="text"><br>
<span>id号:</span><input id="in10" type="text"><br>
<span>政貌:</span><input id="in11" type="text"><br>
<%--<span>日期:</span><input id="in12" type="text"><br>--%>
<span>状态:</span><input id="in13" type="text"><br>
<span>介绍:</span><input id="in14" type="text"><br>
<button id="bt1" >提交</button>
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    function c(){
        var name = document.getElementById("st").options[document.getElementById("st").selectedIndex].innerHTML
        var l = document.getElementById("st").options[document.getElementById("st").selectedIndex].innerHTML.length
        if(l==0){
            var p = document.getElementsByTagName("input")
            console.log(typeof p)
            console.log(p.length===p['length'])
            for(var i=0;i<p.length;i++){
                p[i].style.visibility='hidden'
            }
            var s = document.getElementsByTagName("span")
            console.log(typeof s)
            console.log(s.length===s['length'])
            for(var i=0;i<s.length;i++){
                s[i].style.visibility='hidden'
            }
            var b = document.getElementsByTagName("button")
            console.log(typeof b)
            console.log(b.length===b['length'])
            for(var i=0;i<b.length;i++){
                b[i].style.visibility='hidden'
            }
        }
        if(l>0){

            var p = document.getElementsByTagName("input")
            console.log(typeof p)
            console.log(p.length===p['length'])
            for(var i=0;i<p.length;i++){
                p[i].style.visibility='visible'
            }
            var s = document.getElementsByTagName("span")
            console.log(typeof s)
            console.log(s.length===s['length'])
            for(var i=0;i<s.length;i++){
                s[i].style.visibility='visible'
            }
            var b = document.getElementsByTagName("button")
            console.log(typeof b)
            console.log(b.length===b['length'])
            for(var i=0;i<b.length;i++){
                b[i].style.visibility='visible'
            }
            // document.getElementById("bd").getElementsByTagName("input").css.visibility="visible"
            // document.getElementById("bd").getElementsByTagName("span").css.visibility="visible"
            // document.getElementById("bd").getElementsByTagName("button").css.visibility="visible"
        }
    }

        $("#bt1").click(function (){
            alert(name)
            // var a1 = document.getElementById("in1").value
            var a2 = document.getElementById("in2").value
            var a3 = document.getElementById("in3").value
            var a4 = document.getElementById("in4").value
            var a5 = document.getElementById("in5").value
            var a6 = document.getElementById("in6").value
            var a7 = document.getElementById("in7").value
            var a8 = document.getElementById("in8").value
            var a9 = document.getElementById("in9").value
            var a10 = document.getElementById("in10").value
            var a11 = document.getElementById("in11").value
            // var a12 = document.getElementById("in12").value
            var a13 = document.getElementById("in13").value
            var a14 = document.getElementById("in14").value
            // alert(a1)
            $.getJSON("/insert.do",{n2:a2,n3:a3,n4:a4,n5:a5,n6:a6,n7:a7,n8:a8,n9:a9,n10:a10,n11:a11,n13:a13,n14:a14},function (result){
                    if(result.success){
                        alert("插入成功")
                    }else {
                        alert("插入失败")
                    }
            })
        })

    // function nu(){
    //     if(this.value.length==0){
    //         this.setAttribute("placeholder","不能为空")
    //     }
    // }

    // function cl(name){
    //     alert(name)
    // }
    // $("#bt1").click(function (){
    //
    //     var name = $("#op1").innerHTML
    //
    // })




</script>
</body>
</html>
